package org.gruposp2p.dnie.client.event;

import org.gruposp2p.dnie.client.dto.DocumentToSignDTO;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import java.util.List;

public class SearchDocumentChangeEvent extends GwtEvent {
	
    private static final GwtEvent.Type TYPE = new GwtEvent.Type();

    public DocumentToSignDTO document;
    public List<DocumentToSignDTO> documents;
    public int eventType;
    public int cardinality;
    public static final int EDITED   = 0;
    public static final int DELETED  = 1;
    public static final int ADDED    = 2;
    public static final int MULTIPLE = 3;
    public static final int SINGLE   = 4;

    public static GwtEvent.Type getType(){
       return TYPE;
    }

    @Override
    public Type getAssociatedType() {
        return TYPE;
    }

    @Override
    protected void dispatch(EventHandler handler) {
        ((SearchDocumentChangeHandler)handler).processSearchedDocument(this);
    }

    public SearchDocumentChangeEvent (
            DocumentToSignDTO document, int eventType) {
        this.document = document;
        this.eventType = eventType;
        cardinality = SINGLE;
    }

    public SearchDocumentChangeEvent (List<DocumentToSignDTO> documents) {
        this.documents = documents;
        cardinality = MULTIPLE;
    }

}